package chart;

import java.awt.Shape;

public class DistributedRing extends Ring
{

  public void createSegments()
  {
    if (SegmentsInfo.size() == 0)
    {
      Shape[] shapes = new Shape[1];
      ArcSegment arc = new ArcSegment();
      shapes[0] = arc.Create(x, y, radius, ringwidth, 0, 360);
    } else
    {
      Shape[] shapes = new Shape[SegmentsInfo.size()];
      double sum = 0;
      double span = this.end - this.start;
      for (int i = 0; i < SegmentsInfo.size(); i++)
      {
        sum += SegmentsInfo.get(i).Value;
      }

      double strt = this.start;
      for (int i = 0; i < SegmentsInfo.size(); i++)
      {
        double extent = (SegmentsInfo.get(i).Value / sum) * span;
        ArcSegment arc = new ArcSegment();
        shapes[i] = arc.Create(this.x, this.y, this.radius,
                this.ringwidth, strt, extent / 2);
        strt += extent;
      }

      this.segments = shapes;
    }
  }
}
